package com.jwx.mapper;

import com.jwx.pojo.User;
import org.apache.ibatis.annotations.*;
import java.util.List;


@Mapper
public interface UserMapper {
    @Select("select * from user where username=#{username}")
    User selectUserByName(String username);

    @Insert("insert into user(username,password,create_time,update_time) values(#{username},#{password},now(),now())")
    void insert(String username, String password);

    //        修改一个用户姓名的方法
    @Update("update user set username=#{username},email=#{email},nickname=#{nickname} where id=#{id}")
    User update(User user);

    //        查询所有用户的方法
    @Select("select * from user")
    List<User> selectAllUser();

    //        根据id查找用户
    @Select("select * from where id=#{id}")
    User selectUserById(Integer id);

    @Delete("delete from user where id=#{id}")
    User deleteUser(Integer id);

    @Insert("insert into user(username, password,create_time,update_time values(#{username},#{password},now(),now())")
    int insert01(String username, String password);

    @Insert("update user set user_pic=#{avatarUrl},update_time=now() where id=#{id}")
    void updateAvatar(String avatarUrl, Integer id);

    @Update("update user set password=#{md5String},update_time=now() where id=#{id}")
    void updatePwd(String md5String, Integer id);
}
